----------------- Sprite rotation ----------------- sx The x coordinate of the upper left corner of the rectangle in the sprite sheet. sy The y coordinate of the upper left corner of the rectangle in the sprite sheet. swh The size of the sprite to draw, always square dx The x coordinate of the upper left corner of the rectangle area of the screen. dy The y coordinate of the upper left corner of the rectangle area of the screen. rot How much to rotate this sprite by, ranging from 0 to 1 function spr_rot(sx,sy,swh,dx,dy,rot) local s=sin(rot) local c=cos(rot) local size = swh/2 local _b=(s*s+c*c) local w = sqrt(size^2*2) for y=-w,w do for x=-w,w do local ox=(s*y+c*x)/_b+size local oy=(-s*x+c*y)/_b+size if ox0 and oy>0 then local col=sget(ox+sx,oy+sy) if (col>0) _pset(dx+x,dy+y,col) end end end end